package com.example.demo.service;

import com.example.demo.domain.Comment;
import com.example.demo.mapper.CommentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentService {

    private final CommentMapper commentMapper;

    @Autowired
    public CommentService(CommentMapper commentMapper) {
        this.commentMapper = commentMapper;
    }

    // Get all comments for a particular blog post
    public List<Comment> getCommentsByPostId(Long postId) {
        return commentMapper.findByPostId(postId);
    }

    // Add a new comment
    public void addComment(Comment comment) {
        commentMapper.insert(comment);
    }

    // Delete a comment by ID
    public void deleteComment(Long commentId) {
        commentMapper.deleteById(commentId);
    }

    // Additional service methods can be implemented here
    // ...
}
